/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.scrumpmt.ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.scrumpmt.domain.Esfuerzo;

/**
 *
 * @author aljiru
 */
@Stateless
public class EsfuerzoFacade extends AbstractFacade<Esfuerzo> {
    @PersistenceContext(unitName = "ScrumPMT-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public EsfuerzoFacade() {
        super(Esfuerzo.class);
    }
    
    public List<Esfuerzo> findByTarea(String tarea_id){
        TypedQuery<Esfuerzo> query = em.createQuery("SELECT e FROM Esfuerzo e"
                + " WHERE e.idTareaFk.id = :tarea", Esfuerzo.class);
        query.setParameter("tarea", Long.parseLong(tarea_id));
        
        List<Esfuerzo> result = query.getResultList();
        return (result.size() > 0) ? result : null;
    }
        
}
